/*
 * GYAsyncCmdFactory.h
 *
 *  Created on: 2015年9月22日
 *      Author: gaoyi
 */

#ifndef GYASYNCCMDFACTORY_H_
#define GYASYNCCMDFACTORY_H_


#include "base/CTSingleton.h"

#include <map>
#include <time.h>

using namespace CTLib;

class GYAsyncCmdRegisterInf;
class GYAsyncCmd;
/**
* 异步命令工厂
*/
class GYAsyncCmdFactory
{
public:
	enum
	{
		ENUM_GYASYNC_CMD_FACTORY_MAX_CMD = 0x7FFFFFFF,
	};
public:
	GYAsyncCmdFactory():m_iCmdSeq(0)
	{

	}

	virtual ~GYAsyncCmdFactory()
	{

	}
public:
    //=================================
    // 异步命令的注册/创建/释放

    /**
    * 注册异步命令
    */
	void 			RegisterCmd(int iCmdId, GYAsyncCmdRegisterInf *);
    /**
    * 根据iCmdID创建异步命令
    */
	GYAsyncCmd*		CreateCmd(int iCmdId);
    /**
    * 释放异步命令
    */
	int				FreeCmd(GYAsyncCmd* pstCmd);
protected:
	int				GetCmdSeq();
protected:
	 int											m_iCmdSeq;
protected:
	 std::map<int, GYAsyncCmdRegisterInf *>			m_stCmdRegisterMap;
protected:
	 std::map<int,	GYAsyncCmd *>					m_stCmdSeqMap; // the key is the cmd seq;
};

#define GY_CMDFACTORY		(CTSingleton<GYAsyncCmdFactory>::Instance())


#endif /* GYASYNCCMDFACTORY_H_ */
